package com.virgo.demo.cms.converter;

import com.virgo.common.converter.BaseConverter;
import com.virgo.common.utils.ITimeUtils;
import com.virgo.demo.cms.domain.ArticleDo;
import com.virgo.demo.cms.domain.vo.ArticleListVo;
import com.virgo.demo.support.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ArticleListConverter extends BaseConverter<ArticleDo, ArticleListVo> {

    @Autowired
    private AppService appService;

	@Override
	protected void convert(ArticleDo from, ArticleListVo to) {
		to.setCreatedAt(ITimeUtils.localDate(from.getCreatedAt()));
		to.setUpdatedAt(ITimeUtils.localDate(from.getUpdatedAt()));
		super.convert(from, to);
        to.setImg(appService.getStaticUrl(from.getImg()));
	}
}